using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameScript : MonoBehaviour
{
    public JoystickScript joystick;
    public HeroScript hero;
    public GameObject gameUI;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        Vector3 dir = joystick.GetMoveDirection();
        int speed = 5;
        //移动HeroScript的节点
        hero.transform.position += dir * Time.deltaTime * speed;
        //获取当前摄像机
        Camera camera = Camera.main;
        //设置摄像机的位置
        camera.transform.position = new Vector3(hero.transform.position.x, hero.transform.position.y, camera.transform.position.z);
        gameUI.transform.position = new Vector3(hero.transform.position.x, hero.transform.position.y, gameUI.transform.position.z);
    }
}
